<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title>权限管理</title>
<link rel="stylesheet" href="{{ asset('admin_style/css/pintuer.css') }}">
   <link rel="stylesheet" href="{{ asset('admin_style/css/admin.css') }}">
    <script src="{{asset('admin_style/js/jquery.js')}}"></script>
    <script src="{{asset('admin_style/js/pintuer.js')}}"></script>
<link rel="stylesheet" href="{{asset('admin_style/css/style.css')}}">
<script src="{{asset('admin_style/js/layer/layer.js')}}"></script>
</head>
<body>
  <div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 管理员列表</strong> <a href="" style="float:right; display:none;">添加字段</a></div>
    <div class="amounts_style">
			    <div class="border-b clearfix">
			      <span class="l_f">
			      <a href="JavaScript:;" id="administrator_add" class="button bg-yellow button-small"><span class="icon-plus"></span>添加管理员</a>
			       </span>
			       <span class="r_f">共：<b>5</b>类</span>
			     </div>
			 </div>
    <table class="table table-hover text-center"> 
      @if(Session::get('u_name') == 'admin')
	      <tr>
	        <th width="80" style="text-align:left; padding-left:20px;">编号</th>
	        <th>登录名</th>
	        <th>手机</th>
	        <th>邮箱</th>
	       <!--  <th>角色</th> -->
	        <th width="10%">登录时间</th>
	        <th width="120">操作</th>
	      </tr>
			@foreach($data as $v)
		        <tr>
		          <td style="text-align:left; padding-left:20px;">{{$v->id}}</td>
		          <td>{{$v->u_name}}</td>
		          <td>{{$v->u_phone}}</td>
		          <td>{{$v->u_email}}</td>
		          <td>{{date('Y-m-d H:i:s',$v->u_time)}}</td>
		          <td>
		          		@if($v->u_name == 'admin')
			          		<div class="button-group">
			          			<a class="button border-red" href="{{ url('admin/gly_del/'.$v->id)}}" disabled="false">
			          				<span class="icon-trash-o"></span> 删除
			          			</a>
			          		</div>
		          		@elseif($v->u_name != 'admin')
		          			<div class="button-group">
			          			<a class="button border-red" href="{{ url('admin/gly_del/'.$v->id)}}" >
			          				<span class="icon-trash-o"></span> 删除
			          			</a>
			          		</div>
			          	@endif
		          </td>
		        </tr>
	        @endforeach
	    @elseif(Session::get('u_name') != 'admin')
			<tr>
	        <th width="80" style="text-align:left; padding-left:20px;">编号</th>
	        <th>登录名</th>
	        <th>手机</th>
	        <th>邮箱</th>
	       <!--  <th>角色</th> -->
	        <th width="10%">登录时间</th>
	      </tr>
			@foreach($data as $v)
		        <tr>
		          <td style="text-align:left; padding-left:20px;">{{$v->id}}</td>
		          <td>{{$v->u_name}}</td>
		          <td>{{$v->u_phone}}</td>
		          <td>{{$v->u_email}}</td>
		          <td>{{date('Y-m-d H:i:s',$v->u_time)}}</td>
		        </tr>
	        @endforeach
	    @endif
    </table>
  </div>
  
  
  <!--添加管理员-->
  <div id="add_administrator_style" class="add_menber" style="display:none">
    <form action="{{ url('admin/guan_add')}}" method="post" id="form-admin-add">
		<div class="form-group">
			<label class="form-label"><span class="c-red">*</span>管理员：</label>
			<div class="formControls">
				<input type="text" class="input" value="{{ old('u_name')}}" placeholder="管理员账号" id="user-name" name="u_name">
			</div>
				@if($errors->has('u_name'))
                   <span>{{$errors->first('u_name')}}</span>
                @endif
			<div class="col-4"> <span class="Validform_checktip"></span></div>
		</div>
		<div class="form-group">
			<label class="form-label"><span class="c-red">*</span>初始密码：</label>
			<div class="formControls">
			<input type="password" placeholder="密码" name="u_password" autocomplete="off" value="{{old('u_password')}}" class="input">
			</div>
				@if($errors->has('u_password'))
                   <span>{{$errors->first('u_password')}}</span>
                @endif
			<div class="col-4"> <span class="Validform_checktip"></span></div>
		</div>
		<div class="form-group">
			<label class="form-label "><span class="c-red">*</span>确认密码：</label>
			<div class="formControls ">
		<input type="password" placeholder="确认新密码" autocomplete="off" class="input" errormsg="您两次输入的新密码不一致！" datatype="*" nullmsg="请再输入一次新密码！" recheck="userpassword" id="newpassword2" name="newpassword2">
			</div>
			<div class="col-4"> <span class="Validform_checktip"></span></div>
		</div>
		<div class="form-group">
			<label class="form-label "><span class="c-red">*</span>性别：</label>
			<div class="formControls  skin-minimal">
		      <label><input name="u_sex" type="radio" class="ace" checked="checked" value="保密"><span class="lbl">保密</span></label>&nbsp;&nbsp;
            <label><input name="u_sex" type="radio" class="ace" value="男"><span class="lbl">男</span></label>&nbsp;&nbsp;
            <label><input name="u_sex" type="radio" class="ace" value="女"><span class="lbl">女</span></label>
			</div>
			<div class="col-4"> <span class="Validform_checktip"></span></div>
		</div>
		<div class="form-group">
			<label class="form-label "><span class="c-red">*</span>手机：</label>
			<div class="formControls ">
				<input type="text" class="input" value="{{old('u_phone')}}" placeholder="" id="user-tel" name="u_phone" datatype="m" nullmsg="手机不能为空">
			</div>
				@if($errors->has('u_password'))
                   <span>{{$errors->first('u_password')}}</span>
                @endif
			<div class="col-4"> <span class="Validform_checktip"></span></div>
		</div>
		<div class="form-group">
			<label class="form-label"><span class="c-red">*</span>邮箱：</label>
			<div class="formControls ">
				<input type="text" class="input" placeholder="@" name="u_email" id="email" datatype="e"  value="{{old('u_email')}}">
			</div>
				@if($errors->has('u_password'))
                   <span>{{$errors->first('u_password')}}</span>
                @endif
			<div class="col-4"> <span class="Validform_checktip"></span></div>
		</div>
		<div class="form-group">
			<label class="form-label">备注：</label>
			<div class="formControls">
				<textarea name="u_remarks" class="input" cols="" rows="" class="textarea" placeholder="说点什么...100个字符以内" dragonfly="true" onkeyup="checkLength(this);">{{ old('u_remarks')}}</textarea>
				<span class="wordage">剩余字数：<span id="sy" style="color:Red;">100</span>字</span>
			</div>
			<div class="col-4"> </div>
		</div>
		<div class="text-center"> 
		<input type="hidden" name="_token" value="{{csrf_token()}}">
        <input class="button bg-main " type="submit" id="Add_Administrator" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
	
   </div>
   </form>
 </div> 
<script type="text/javascript">


/*添加管理员*/
$('#administrator_add').on('click', function(){
	layer.open({
    type: 1,
	title:'添加管理员',
	area: ['700px',''],
	shadeClose: false,
	content: $('#add_administrator_style'),
	
	});
})
	
//字数限制
function checkLength(which) {
	var maxChars = 100; //
	if(which.value.length > maxChars){
	   layer.open({
	   icon:2,
	   title:'提示框',
	   content:'您输入的字数超过限制!',	
    });
		// 超过限制的字数了就将 文本框中的内容按规定的字数 截取
		which.value = which.value.substring(0,maxChars);
		return false;
	}else{
		var curr = maxChars - which.value.length; //250 减去 当前输入的
		document.getElementById("sy").innerHTML = curr.toString();
		return true;
	}
};
</script>
</body>
</html>
